﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;
using System.Collections;

namespace GPCSC.Webs
{
    public class SqlReadXml
    {
        ReadXml RX = new ReadXml();
        public SqlReadXml()
        {
        }

        public DataSet ReaderDataSet(string sql, object parameterObject)
        {
            string strname = sql;
            SqlParameter cmdParm;
            Hashtable hastable = (Hashtable)parameterObject;
            SqlCommand cmd = new SqlCommand();
            foreach (DictionaryEntry list in hastable)
            {
                cmdParm = new SqlParameter(list.Key.ToString(), list.Value);
                cmd.Parameters.Add(cmdParm);
            }

            return RX.SearchData(cmd, strname);
        }

        public DataSet ReaderDataSet(string sql)
        {
            return RX.SearchData(sql);
        }

        //无返回值的
        public int NotDoSQL(string sql, object parameterObject)
        {
            string strname = sql;
            SqlParameter cmdParm;
            Hashtable hastable = (Hashtable)parameterObject;
            SqlCommand cmd = new SqlCommand();
            foreach (DictionaryEntry list in hastable)
            {
                cmdParm = new SqlParameter(list.Key.ToString(), list.Value);
                cmd.Parameters.Add(cmdParm);
            }

            return RX.NotDoSQL(cmd, strname);
        }


        //直接使用语句
        public DataSet DsDoSQL(string sql, object parameterObject)
        {
            string strname = sql;
            SqlParameter cmdParm;
            Hashtable hastable = (Hashtable)parameterObject;
            SqlCommand cmd = new SqlCommand();
            foreach (DictionaryEntry list in hastable)
            {
                cmdParm = new SqlParameter(list.Key.ToString(), list.Value);
                cmd.Parameters.Add(cmdParm);
            }

            return RX.DsDoSQL(cmd, strname);
        }

        public string SqlBack(string sql)
        {
            return RX.SqlBack(sql);
        }
    }
}
